<template>
  <div class="home">
    <div class="square_header flex align_center">
      <div
        class="square_header_item"
        :class="active == index ? 'underline ' : ''"
        v-for="(item,index) in activity"
        :key="index"
        @click="checkItem(index)"
      >
        <span
          :class="active == index ? 'title1 color1 zIndex fontBold ' : 'default'"
        >{{ item.name }}</span>
      </div>
    </div>
    <component :is="active == 0 ? Qiye : Renmai " />
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import Qiye from './qiye.vue'
import Renmai from './renmai.vue'
import { useRouter, useRoute } from 'vue-router'
const router = useRouter()
const route = useRoute()
const active: any = ref(route.query.s || 0)
const activity: any = ref([
  {
    name: '企业'
  },
  {
    name: '人脉'
  }
])

const checkItem = (index:any) => {
  active.value = index
  router.replace({
    path: '/square',
    query: { s: index }
  })
}

// const company = async (id:any) => {
//   router.push({ path: '/square/company', query: { id: id } })
// }

</script>

<style lang="less" scoped>
.home {
    margin: 0 15px;
    .my-swipe {
        width: 100%;
        height: 146px;
        background: #ff7a1f;
        box-shadow: 0px 2px 10px 0px rgba(238, 150, 103, 0.5);
        border-radius: 5px;
        margin: 20px auto;
        img {
            // width: 100%;
            height: 146px;
            object-fit: cover;
        }
    }
    .onSearch {
        border-radius: 5px;
        margin-bottom: 20px;
        .label_icon {
            overflow: hidden;
            display: flex;
            align-items: center;
            .icon {
                width: 34px;
                height: 34px;
                object-fit: cover;
                margin-right: 14px;
            }
            span {
                margin: 0 14px 0 0;
                color: #d8d8d8;
            }
        }

        .van-field__left-icon {
            display: none;
        }
    }
}
.square_header {
    width: 100%;
    height:52px;
    margin-top: 10px;
    position: sticky;
    top: 0;
    z-index: 10;
    background: #f7f7f7;
    .square_header_item {
        margin-right: 29px;
        .default {
            font-size: 19px;
            font-weight: bold;
            color: #454757;
        }
    }
}
@media (min-width: 750px) {
  .home {
    margin: 0 15px;
    .my-swipe {
        width: 100%;
        height: 146px;
        background: #ff7a1f;
        box-shadow: 0px 2px 10px 0px rgba(238, 150, 103, 0.5);
        border-radius: 5px;
        margin: 20px auto;
        img {
            // width: 100%;
            height: 146px;
            object-fit: cover;
        }
    }
    .onSearch {
        border-radius: 5px;
        margin-bottom: 20px;
        .label_icon {
            overflow: hidden;
            display: flex;
            align-items: center;
            .icon {
                width: 34px;
                height: 34px;
                object-fit: cover;
                margin-right: 14px;
            }
            span {
                margin: 0 14px 0 0;
                color: #d8d8d8;
            }
        }

        .van-field__left-icon {
            display: none;
        }
    }
}
.square_header {
    width: 100%;
    height:52px;
    margin-top: 10px;
    position: sticky;
    top: 0;
    z-index: 10;
    background: #f7f7f7;
    .square_header_item {
        margin-right: 29px;
        .default {
            font-size: 19px;
            font-weight: bold;
            color: #454757;
        }
    }
}
}
</style>
